<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author FIRE
-->
<template>
  <div>
    <BasicTable
      @register="registerTable"
      :rowClassName="getRowClassName"
      @expand="onExpand"
      :expandedRowKeys="expands"
    >
      <template #tableTitle>
        <Icon :icon="getTitle.icon" class="m-1 pr-1" />
        <span> {{ getTitle.value }} </span>
      </template>
      <!-- <template #toolbar>
        <a-button
          type="primary"
          @click="handleDownload({})"
          v-auth="'proj:info:pmProjectinformation:view'"
        >
          <Icon icon="ant-design:cloud-download-outlined" /> {{ t('下载安全检查表') }}
        </a-button>
      </template> -->
      <template #firstColumn="{ record }">
        <!-- <a @click.stop="handleForm(record)">
          <span style="text-decoration: underline; margin-right: 5px">查看</span>
        </a>
        {{ record.projectno }} -->
        <a @click.stop="handleForm(record)">
          {{ record.projectno }}
        </a>
      </template>

      <template #operate="{ record }">
        <!-- style="color: rgb(255, 255, 0);"
style="color: rgb(255, 255, 0);" -->
        <a @click.stop="handleCancel(record)" v-if="record.bcollection == '1'">
          <Icon icon="ant-design:star-filled" size="18" />
        </a>
        <a @click.stop="handleSave(record)" v-else>
          <Icon icon="ant-design:star-outlined" size="18" />
        </a>
      </template>

      <!-- <template #pmJournal="{ record }">
        {{record.bcheckIn=='1'?'已打卡':'未打卡'}}
      </template> -->
      <!-- <template #expandedRowRender="{ record }">
        <div style="padding: 10px">
          <div style="display: flex; background: #f9f9f9; padding: 23px 0px 28px 18px">
            <div style="flex: 1">
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >申请主体</span
                >
                <span style="font-size: 12px; color: #333">{{ record.applybodyname }} </span>
              </div>
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >项目特征</span
                >
                <span style="font-size: 12px; color: #333">{{ record.projecttype }} </span>
              </div>
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >监理单位</span
                >
                <span style="font-size: 12px; color: #333">{{ record.projectno }} </span>
              </div>
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >接件时间</span
                >
                <span style="font-size: 12px; color: #333">{{ record.createtime }} </span>
              </div>
            </div>
            <div style="flex: 1">
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >联系人</span
                >
                <span style="font-size: 12px; color: #333">{{ record.contacts }} </span>
              </div>
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >工程类型</span
                >
                <span>{{ record.status }} </span>
              </div>
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >设计人员</span
                >
                <span style="font-size: 12px; color: #333">{{ record.projectno }} </span>
              </div>
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >需要中间验收</span
                >
                <span style="font-size: 12px; color: #333">{{ record.projectno }} </span>
              </div>
            </div>
            <div style="flex: 1">
              <div style="margin-bottom: 20px">
                <span
                  style="
                    width: 100px;
                    color: #aaa;
                    display: inline-block;
                    font-size: 12px;
                    color: #999;
                  "
                  >联系电话</span
                >
                <span style="font-size: 12px; color: #333">{{ record.mobile }} </span>
              </div>
            </div>
            <div style="flex: 1"></div>
          </div>

          <div style="display: flex; flex-direction: row-reverse; margin-top: 25px">
            <div>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm({})"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="ant-design:check-circle-outlined" /> {{ t('打卡') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm({})"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="ant-design:calendar-outlined" /> {{ t('周报') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm({})"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="simple-line-icons:cursor" /> {{ t('巡检') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm({})"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="ant-design:hourglass-twotone" /> {{ t('报装附件') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm({})"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="ant-design:calendar-outlined" /> {{ t('报装日志') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm({})"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="ant-design:profile-twotone" /> {{ t('设计变更') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm({})"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="simple-line-icons:list" /> {{ t('预算执行表') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleRwfpForm(record)"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="simple-line-icons:puzzle" /> {{ t('任务分配') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm(record)"
                v-auth="'proj:info:pmProjectinformation:edit'"
              >
                <Icon icon="clarity:note-edit-line" /> {{ t('编辑') }}
              </a-button>
            </div>
          </div>
        </div>
      </template> -->

      <template #expandedRowRender="{ record }">
        <div style="padding: 10px">
          <div style="background: #f9f9f9; padding: 23px 18px 28px 18px">
            <a-row>
              <template v-for="(item, index) in listForm" :key="index">
                <a-col :span="item.colProps.lg">
                  <div style="margin-bottom: 20px; margin-right: 20px">
                    <span
                      style="
                        width: 100px;
                        display: inline-block;

                        color: #999;
                      "
                      >{{ item.label }}</span
                    >
                    <!-- <DictLabel
                      v-if="record[item.field] && item.component=='Select'"
                      :dictType="item.componentProps.dictType"
                      :dictValue="record[item.field]"
                      :defaultValue="record[item.field]==1?'是':'否'"
                    /> -->
                    <DictLabel
                      v-if="record[item.field] && item.component == 'Select'"
                      :dictType="item.componentProps.dictType"
                      :dictValue="record[item.field]"
                      :defaultValue="record[item.field]"
                    />

                    <!-- <span v-else style=" color: #333">{{ record[item.field]}} </span> -->
                    <span v-else style="color: #333">{{ handleFields(item.field, record) }} </span>
                  </div>
                </a-col>
              </template>
            </a-row>
          </div>
          <div style="display: flex; flex-direction: row-reverse; margin-top: 25px">
            <!-- type="primary" -->
            <div>
              <!--    -->
              <a-button class="ml-1 ml-expand" @click="handlezxqk(record)" v-auth="'btn:zxqk'">
                <Icon icon="ant-design:zoom-in-outlined" /> {{ t('查看材料执行情况') }}
              </a-button>

              <a-button class="ml-1 ml-expand" @click="handlebzzt(record)" v-auth="'btn:bzzt'">
                <Icon icon="ant-design:eye-filled" /> {{ t('查看报装项目状态') }}
              </a-button>
              <a-button
                v-if="record.bcheckIn != '1'"
                class="ml-1 ml-expand"
                @click="handledaka(record)"
                v-auth="'btn:daka'"
              >
                <Icon icon="ant-design:check-circle-outlined" /> {{ t('打卡') }}
              </a-button>
              <a-button
                v-if="record.projStatus == '2'"
                class="ml-1 ml-expand"
                @click="handlexmzb(record)"
                v-auth="'btn:list:zhuobao'"
              >
                <Icon icon="ant-design:calendar-outlined" /> {{ t('周报') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handlecbsAdd(record)"
                v-auth="'btn:add:shigongdui'"
              >
                <Icon icon="fluent:add-12-filled" /> {{ t('添加施工队') }}
              </a-button>
              <a-button class="ml-1 ml-expand" v-auth="'btn:xunjian'" @click="handleXj(record)">
                <Icon icon="simple-line-icons:cursor" /> {{ t('巡检') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                v-auth="'btn:baozhuangfujian'"
                @click="handleBzfj(record)"
              >
                <Icon icon="ant-design:hourglass-twotone" /> {{ t('报装附件') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                v-auth="'btn:baozhuangrizhi'"
                @click="handleBzLog(record)"
              >
                <Icon icon="ant-design:calendar-outlined" /> {{ t('报装日志') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                v-auth="'btn:shejibiangeng'"
                @click="handleXjbg(record)"
              >
                <Icon icon="ant-design:profile-twotone" /> {{ t('设计变更') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                v-auth="'btn:yusuanzhixing'"
                @click="handleYszxb(record)"
              >
                <Icon icon="simple-line-icons:list" /> {{ t('预算执行表') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleRwfpForm(record)"
                v-auth="'btn:proj:task:fp'"
              >
                <Icon icon="simple-line-icons:puzzle" /> {{ t('任务分配') }}
              </a-button>
              <a-button
                class="ml-1 ml-expand"
                @click="handleForm(record)"
                v-auth="'proj:info:pmProjectinformation:view'"
              >
                <Icon icon="clarity:note-edit-line" /> {{ t('查看详情') }}
              </a-button>
            </div>
          </div>
        </div>
      </template>
      <!-- <template #actionOperation="{ record }">
        <span v-if="isCurrentExpandedRow(record)">
          {{ t('收起') }} <Icon icon="ant-design:up-outlined" size="8" />
        </span>
        <span v-else> {{ t('展开') }} <Icon icon="ant-design:down-outlined" size="8" /> </span>
      </template> -->
    </BasicTable>
    <InputForm @register="registerDrawer" @success="handleSuccess" />
    <!-- 任务分配 -->
    <RwfpForm @register="registerRwfpDrawer" @success="handleSuccess" />
    <!-- 项目周报 -->
    <xmzbFrom @register="registerXmzbDrawer" @success="handleSuccess" />
    <!-- 添加承包商 -->
    <cbsForm @register="registerCbsDrawer" @success="handleSuccess" />
    <!-- 报装附件列表 -->
    <BasicDrawer
      v-bind="$attrs"
      :showFooter="true"
      :showOkBtn="false"
      @register="registerAttachmentDrawer"
      width="80%"
      title="报装附件"
    >
      <AttachmentList :projectno="projectno" />
    </BasicDrawer>
    <!-- 报装日志列表 -->
    <BasicDrawer
      v-bind="$attrs"
      :showFooter="true"
      :showOkBtn="false"
      @register="registerBzLogDrawer"
      width="80%"
      title="报装日志"
    >
      <BzLogList :projectno="projectno" />
    </BasicDrawer>

    <!-- 设计变更列表 -->
    <BasicDrawer
      v-bind="$attrs"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerXjbgDrawer"
      width="80%"
      title="设计变更"
    >
      <XjbgList :projectno="projectno" />
    </BasicDrawer>

    <!-- 设计变更列表 -->
    <BasicDrawer
      v-bind="$attrs"
      :showFooter="false"
      :showOkBtn="false"
      @register="registerYszxbDrawer"
      width="80%"
      title="预算执行表"
    >
      <YszxbList :projectno="projectno" />
    </BasicDrawer>

    <XjForm @register="registerXjDrawer" @success="handleSuccess" />

    <Modal @register="registerModal" />
  </div>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'ViewsProjInfoPmProjectinformationList',
  });
</script>
<script lang="ts" setup>
  import { defineComponent, onMounted, ref } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
  import {
    getBzStatus,
    pmProjectinformationDelete,
    pmProjectinformationListData,
    userCollectSave,
    userCollectCancel,
    userCollectListDataNoPage,
  } from '/@/api/proj/info/pmProjectinformation';
  import { BasicDrawer, useDrawer } from '/@/components/Drawer';
  import { FormProps } from '/@/components/Form';
  import { customListData, listSet, formSet } from '/@/api/test/testData';
  import { schemasData, tabConfigData, formSchemas } from '/@/utils/custom';
  import InputForm from './form.vue';
  import cbsForm from './cbsForm.vue';
  import RwfpForm from '../pmZoneallocation/formTabs.vue';
  import { DictLabel } from '/@/components/Dict';
  import { useModal } from '/@/components/Modal';
  import { downloadByUrl } from '/@/utils/file/download';
  import { useGlobSetting } from '/@/hooks/setting';
  import Modal from './modal.vue';

  import { pmJournalSave } from '/@/api/proj/journal/pmJournal';

  import { useUserStore } from '/@/store/modules/user';
  import { useLoading } from '/@/components/Loading';

  import xmzbFrom from '/@/views/proj/weekly/pmWeekly/form.vue';
  import AttachmentList from '../../attachment/pmAttachment/list.vue';
  import BzLogList from './bzLog.vue';

  import XjForm from '/@/views/proj/xj/pmInspection/form.vue';

  import XjbgList from '/@/views/design/change/pmDesignchange/list.vue';

  import YszxbList from '/@/views/material/bom/pmMaterial/list.vue';

  const userStore = useUserStore();

  const [openFullLoading, closeFullLoading] = useLoading({
    tip: '加载中...',
  });

  // 定义一个 ref 来跟踪当前展开的行记录
  const expandedRowRecord = ref(null);
  const { t } = useI18n('proj.info.pmProjectinformation');
  const { showMessage, showMessageModal } = useMessage();
  const getTitle = {
    icon: router.currentRoute.value.meta.icon || 'ant-design:book-outlined',
    value: router.currentRoute.value.meta.title || t('项目信息管理'),
  };
  let expands = ref<any>([]);

  let listForm = ref<any>([]);

  let tableColumns = ref<any>([]);

  let layVoucherView = ref<any>({});
  let listTabConfig = ref<any>({});
  const projectno = ref<any>('');

  const searchForm = ref<FormProps>({
    baseColProps: { lg: 6, md: 8 }, // 表单栅格布局
    labelWidth: 90, // 表单标签宽度
    schemas: [],
    fieldMapToTime: [['createtime', ['createtime_gte', 'createtime_lte']]],
  });

  const isCurrentExpandedRow = (record: any) => {
    return expandedRowRecord.value && record === expandedRowRecord.value;
  };

  const actionColumn: BasicColumn = {
    width: 80,
    actions: (record: Recordable) => [
      // {
      //   icon: 'clarity:note-edit-line',
      //   title: t('编辑项目信息'),
      //   onClick: handleForm.bind(this, { id: record.id }),
      //   auth: 'proj:info:pmProjectinformation:edit',
      // },
      {
        icon: 'ant-design:star-outlined',
        // label:'收藏',
        title: t('收藏'),
        onClick: handleSave.bind(this, record),
        auth: 'btn:collect',
        ifShow: () => record.bcollection != '1',
      },
      {
        icon: 'ant-design:star-filled',
        // label:'取消收藏',
        title: t('取消收藏'),
        onClick: handleCancel.bind(this, record),
        auth: 'btn:collect',
        ifShow: () => record.bcollection == '1',
      },
    ],
  };

  const [registerModal, { openModal }] = useModal();

  const [registerDrawer, { openDrawer }] = useDrawer();

  const [registerXjDrawer, { openDrawer: openXjDrawer }] = useDrawer();
  const [registerRwfpDrawer, { openDrawer: openRwfpDrawer }] = useDrawer();
  const [registerXmzbDrawer, { openDrawer: openXmzbDrawer }] = useDrawer();
  const [registerCbsDrawer, { openDrawer: openCbsDrawer }] = useDrawer();
  const [registerAttachmentDrawer, { openDrawer: openAttachmentDrawer }] = useDrawer();
  const [registerBzLogDrawer, { openDrawer: openBzLogDrawer }] = useDrawer();
  const [registerXjbgDrawer, { openDrawer: openXjbgDrawer }] = useDrawer();
  const [registerYszxbDrawer, { openDrawer: openYszxbDrawer }] = useDrawer();

  const [registerTable, { reload, getForm, setProps, updateTableDataRecord }] = useTable({
    // api: pmProjectinformationListData,
    // beforeFetch: (params) => {
    //   return params;
    // },
    // columns: tableColumns,
    // actionColumn: actionColumn,
    // formConfig: searchForm,
    // showTableSetting: true,
    // useSearchForm: true,
    canResize: true,
    immediate: false,
    expandRowByClick: true,
    accordion: false, // 手风琴效果,
    bordered: false,
    columns: tableColumns,
    formConfig: searchForm.value as FormProps,
  });

  async function handlexmzb(record) {
    openXmzbDrawer(true, { projectno: record.projectno });
  }

  async function handlecbsAdd(record: Recordable) {
    openCbsDrawer(true, { id: record.id });
  }
  async function handleXj(record: Recordable) {
    openXjDrawer(true, {
      projectno: record.projectno,
      name: record.projectname,
    });
  }

  async function handlebzzt(record: Recordable) {
    let res = await getBzStatus({ id: record.id });
    if (res.data.result) {
      openModal(true, { ...record, ...res.data });
    } else {
      showMessageModal({ content: res.data.error, okText: '关闭' }, 'error');
    }
  }

  async function handledaka(record) {
    console.log(record);
    try {
      // const data = await validate();
      // setDrawerProps({ confirmLoading: true });
      openFullLoading();
      const params: any = {
        projectno: record.projectno,
      };
      // console.log('submit', params, data, record);
      const res = await pmJournalSave(params);
      showMessage(res.message);
      // setTimeout(closeDrawer);
      // emit('success', data);
      handleSuccess();
    } catch (error: any) {
      if (error && error.errorFields) {
        showMessage(t('您填写的信息有误，请根据提示修正。'));
      }
      console.log('error', error);
    } finally {
      closeFullLoading();
      // setDrawerProps({ confirmLoading: false });
    }
  }

  // function getRowClassName(row, index) {
  //   console.log(row, index);
  //   if (index === 1) {
  //     return 'rowcolor'; // 第二行设置为高亮行
  //   } else {
  //     return ''; // 其他行不设置特定的CSS类名
  //   }
  // }

  // 获取行类名的方法
  const getRowClassName = (record: any, index) => {
    // 判断当前行是否为展开状态

    const isExpandedRow = record === expandedRowRecord.value;
    // if (record.pmDelay && record.pmDelay.isDelay == '1') {
    //   return 'rowcolor'; // 设置变红
    // } else {
    // 返回对应的类名，根据 isExpandedRow 添加额外的类名以改变背景色
    return [
      'project-row-class', // 替换为实际的基础行类名（如有）
      isExpandedRow ? 'ant-table-expanded-row-current' : '',
    ]
      .filter(Boolean)
      .join(' ');
    // }
  };

  // 当展开行状态变化时更新 expandedRowRecord
  const onExpand = (expanded: boolean, record: any) => {
    if (expands.value[0] == record.id) {
      expands.value = [];
    } else {
      expands.value = [];
      expands.value.push(record.id);
    }
    console.log('expanded', expanded, record);
    console.log('expands', expands.value);
    if (expanded) {
      expandedRowRecord.value = record;
    } else {
      expandedRowRecord.value = null;
    }
  };

  function handleForm(record: Recordable) {
    // openDrawer(true, record);
    router.push({
      path: '/proj/info/pmProjectinformation/detailsForm',
      query: {
        // projectno: code,
        id: record.id,
        code: record.projectno,
        tabTitle: `项目详情(${record.projectno})`,
      },
    });
  }

  function handlezxqk(record: Recordable) {
    router.push({
      path: '/proj/info/pmProjectinformation/zxqkIndex',
      query: {
        code: record.projectno,
        tabTitle: `${record.projectno} / ${new Date().getTime()}`,
      },
    });
  }

  async function handleSave(record: Recordable) {
    let data = {
      projectCode: record.projectno,
      projectName: record.projectname,
    };
    const res = await userCollectSave(data);
    showMessage(res.message);

    // updateTableDataRecord(record.id,{
    //   ...record,
    //   bcollection:1
    // })
    record.bcollection = '1';
    // handleSuccess();

    let res1 = await userCollectListDataNoPage();
    await userStore.setProjecteList(res1);
  }

  async function handleCancel(record: Recordable) {
    let data = {
      projectCode: record.projectno,
      // projectName:record.projectname
    };
    const res = await userCollectCancel(data);
    showMessage(res.message);
    record.bcollection = '0';
    // handleSuccess();
    // updateTableDataRecord(record.id,{
    //   ...record,
    //   bcollection:'0'
    // })

    let res1 = await userCollectListDataNoPage();
    // console.log(res1);
    await userStore.setProjecteList(res1);
  }

  async function handleDelete(record: Recordable) {
    const res = await pmProjectinformationDelete(record);
    showMessage(res.message);
    handleSuccess();
  }

  function handleSuccess() {
    reload();
  }

  function handleFields(fields, record) {
    let arr = fields.split('.');
    let str = '';
    if (arr.length == 1) {
      str = record[fields];
    }
    if (arr.length == 2 && record[arr[0]]) {
      str = record[arr[0]][arr[1]];
    }
    if (arr.length == 3 && record[arr[0]] && record[arr[0]][arr[1]]) {
      str = record[arr[0]][arr[1]][arr[2]];
    }
    if (
      arr.length == 4 &&
      record[arr[0]] &&
      record[arr[0]][arr[1]] &&
      record[arr[0]][arr[1]][arr[2]]
    ) {
      str = record[arr[0]][arr[1]][arr[2]][arr[3]];
    }
    return str;
  }
  async function handlelistForm() {
    let viewCode = 'sxyf_proj_info_form_list';
    const res11 = await formSet({ viewCode });
    // formTabs.value = res11.layVoucherView.formTabs;
    // formConfig.value = res11.layVoucherView.formConfig;
    listForm.value = formSchemas(res11.layVoucherView.formTabs[0].colList, 8, {}) as FormSchema[];
    console.log(listForm.value, 'inputFormSchemas=====');
  }

  onMounted(async () => {
    await handlelistForm();
    const res = await listSet({ viewCode: 'sxyf_proj_info_list001' });
    // title.value = res.layVoucherView.name;
    layVoucherView.value = res.layVoucherView;
    searchForm.value.schemas = schemasData(layVoucherView.value.listQuery?.queryCols);
    searchForm.value.schemas?.forEach((item) => {
      if (item.field == 'ope') {
        item.defaultValue = false;
        item.componentProps = {
          onChange: handleSuccess,
        };
      }
    });
    tableColumns.value = layVoucherView.value.flistTabCols; //表格表头
    // butData.value = layVoucherView.value.headBtns; //表格右上角按钮
    // actionColumnData.value = layVoucherView.value.rowBtns; //表格行内按钮
    listTabConfig.value = tabConfigData(res.layVoucherView.listTabConfig);
    await setProps({
      api: customListData,
      beforeFetch: (params) => {
        params.url = listTabConfig.value.api;
        return params;
      },
      autoCreateKey: listTabConfig.value.autoCreateKey,
      bordered: listTabConfig.value.bordered,
      canResize: listTabConfig.value.canResize,
      clearSelectOnPageChange: listTabConfig.value.clearSelectOnPageChange,
      clickToRowSelect: listTabConfig.value.clickToRowSelect,
      ellipsis: listTabConfig.value.ellipsis,
      emptyDataIsShowTable: listTabConfig.value.emptyDataIsShowTable,
      inset: listTabConfig.value.inset,
      isTreeTable: listTabConfig.value.isTreeTable,
      pagination: listTabConfig.value.pagination,
      showIndexColumn: listTabConfig.value.showIndexColumn,
      showSummary: listTabConfig.value.showSummary,
      showTableSetting: listTabConfig.value.showTableSetting,
      striped: listTabConfig.value.striped,
      useSearchForm: listTabConfig.value.useSearchForm,
      tableSetting: listTabConfig.value.tableSetting,
      titleHelpMessage: listTabConfig.value.titleHelpMessage,
      maxHeight: listTabConfig.value.maxHeight,
      resizeHeightOffset: listTabConfig.value.resizeHeightOffset,
    });
    // if (!listTabConfig.value.immediate) {
    //   reload();
    // }
    handleProjecte();
  });
  async function handleProjecte() {
    await getForm().setFieldsValue({
      projectno: router.currentRoute.value.query.projectno
        ? router.currentRoute.value.query.projectno
        : userStore.getProjecte.code,
    });
    reload();
    await getForm().setFieldsValue({
      projectno: router.currentRoute.value.query.projectno
        ? router.currentRoute.value.query.projectno
        : userStore.getProjecte.code,
    });
  }

  /**
   * 打开任务分派FORM
   * @param record
   */
  function handleRwfpForm(record: Recordable) {
    openRwfpDrawer(true, { id: record.id });
  }

  /**
   * 打开报装附件列表
   * @param record
   */
  function handleBzfj(record: Recordable) {
    console.log(record);
    projectno.value = record.projectno;
    openAttachmentDrawer();
  }

  /**
   * 打开报装日志列表
   * @param record
   */
  function handleBzLog(record: Recordable) {
    console.log(record);
    projectno.value = record.projectno;
    openBzLogDrawer();
  }

  /**
   * 打开设计变更列表
   * @param record
   */
  function handleXjbg(record: Recordable) {
    console.log(record);
    projectno.value = record.projectno;
    openXjbgDrawer();
  }

  /**
   * 预算执行表
   * @param record
   */
  function handleYszxb(record: Recordable) {
    console.log(record);
    projectno.value = record.projectno;
    openYszxbDrawer();
  }

  /**
   * 工程项目施工现场安全检查表下载
   * 单个项目
   */
  function handleDownload() {
    const { ctxPath } = useGlobSetting();
    console.log(expandedRowRecord.value);
    if (expandedRowRecord.value) {
      downloadByUrl({
        url:
          ctxPath +
          `/ureport/pdf?_u=file:安全检查表.ureport.xml&id=${expandedRowRecord.value.id}&_n=工程项目施工现场安全检查表.pdf`,
        target: '_self',
      });
    } else {
      showMessage('请先选择项目！');
    }
  }
</script>
<style>
  /* th {
    padding: 9px 8px !important;
    color: #999999;
    font-size: 12px;
  } */
</style>
<style lang="less">
  .ant-table-expanded-row-fixed {
    background-color: #fff !important;
    border: 1px solid #edeeff;
  }
  /* 添加针对展开行的自定义样式 */
  .ant-table-expanded-row-current {
    td {
      background-color: #edeeff !important;
      color: #3e4399 !important;
    }
  }
  .project-row-class {
    position: relative;
    td {
      background: #f7f7f7;
      color: #333333;
      /* font-size: 12px; */
    }
  }
  .ml-expand {
    border: 1px solid #000;
    color: #000;
  }
  /* .project-row-class::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #fff;
    z-index: 999;
    color: #999999;
  } */

  .rowcolor {
    td {
      background-color: rgba(255, 0, 0, 0.7) !important;
    }
  }
</style>
